<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />
      <!--表单组件-->
      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
          <el-form-item label="入院日期" prop="bisJzdjRyrq">
            <el-date-picker v-model="form.bisJzdjRyrq" type="datetime" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="科室名称" prop="bisJzdjKsmc">
            <el-input v-model="form.bisJzdjKsmc" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="病室" prop="bisJzdjBs">
            <el-input v-model="form.bisJzdjBs" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="床位号" prop="bisJzdjCwh">
            <el-input v-model="form.bisJzdjCwh" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="医生姓名" prop="bisJzdjYsxm">
            <el-input v-model="form.bisJzdjYsxm" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="患者联系方式" prop="bisJzdjHzlxfs">
            <el-input v-model="form.bisJzdjHzlxfs" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="家属联系方式">
            <el-input v-model="form.bisJzdjJslxfs" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="审批开始时间" prop="bisJzdjSpkssj">
            <el-input v-model="form.bisJzdjSpkssj" style="width: 370px;" />
          </el-form-item>
          <el-form-item label="审批终止时间" prop="bisJzdjSpzzsj">
            <el-input v-model="form.bisJzdjSpzzsj" style="width: 370px;" />
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="text" @click="crud.cancelCU">取消</el-button>
          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
        </div>
      </el-dialog>
      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="bisJzdjLsh" label="就诊流水号" />
        <el-table-column prop="bisJzdjYllb" label="医疗类别" />
        <el-table-column prop="bisJzdjRyrq" label="入院日期" />
        <el-table-column prop="bisJzdjCyrq" label="出院日期" />
        <el-table-column prop="bisJzdjRyjbbm" label="入院疾病编码" />
        <el-table-column prop="bisJzdjCyjbbm" label="出院疾病编码" />
        <el-table-column prop="bisJzdjJbr" label="经办人" />
        <el-table-column prop="bisJzdjJbrq" label="经办日期" />
        <el-table-column v-if="checkPer(['admin','jzdj:edit','jzdj:del'])" label="操作" width="150px" align="center">
          <template slot-scope="scope">
            <udOperation
              :data="scope.row"
              :permission="permission"
            />
          </template>
        </el-table-column>
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import crudJzdj from '@/api/business/jzdj'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { bisJzdjId: null, bisJzdjZhsqId: null, bisJzdjLsh: null, bisJzdjYllb: null, bisJzdjRyrq: null, bisJzdjCyrq: null, bisJzdjRyjbbm: null, bisJzdjGhf: null, bisJzdjZcf: null, bisJzdjCyjbbm: null, bisJzdjJbr: null, bisJzdjJbrq: null, bisJzdjFph: null, bisJzdjCyzt: null, bisJzdjSpr: null, bisJzdjZcyymc: null, bisJzdjKsmc: null, bisJzdjBs: null, bisJzdjCwh: null, bisJzdjYsxm: null, bisJzdjHzlxfs: null, bisJzdjJslxfs: null, bisJzdjSpkssj: null, bisJzdjSpzzsj: null, ywlx: null, lrr: null, lrrxm: null, lrbm: null, lrbmmc: null, lrsj: null, gxr: null, gxrxm: null, gxbm: null, gxbmmc: null, gxsj: null, sfyx: null, bz: null }
export default {
  name: 'Jzdj',
  components: { pagination, crudOperation, rrOperation, udOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  cruds() {
    return CRUD({ title: '就诊登记', url: 'api/jzdj', idField: 'bisJzdjId', sort: 'bisJzdjId,desc', crudMethod: { ...crudJzdj }})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'jzdj:add'],
        edit: ['admin', 'jzdj:edit'],
        del: ['admin', 'jzdj:del']
      },
      rules: {
        bisJzdjRyrq: [
          { required: true, message: '入院日期不能为空', trigger: 'blur' }
        ],
        bisJzdjKsmc: [
          { required: true, message: '科室名称不能为空', trigger: 'blur' }
        ],
        bisJzdjBs: [
          { required: true, message: '病室不能为空', trigger: 'blur' }
        ],
        bisJzdjCwh: [
          { required: true, message: '床位号不能为空', trigger: 'blur' }
        ],
        bisJzdjYsxm: [
          { required: true, message: '医生姓名不能为空', trigger: 'blur' }
        ],
        bisJzdjHzlxfs: [
          { required: true, message: '患者联系方式不能为空', trigger: 'blur' }
        ],
        bisJzdjSpkssj: [
          { required: true, message: '审批开始时间不能为空', trigger: 'blur' }
        ],
        bisJzdjSpzzsj: [
          { required: true, message: '审批终止时间不能为空', trigger: 'blur' }
        ]
      }}
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
